package speed;

import java.text.CharacterIterator;

public class Convert {

	public static void main(String[] args) {
		System.out.println("------------------------------------");
		System.out.println("AutoConvert");
		//char int long float double
		//byte short int long float double
		double d = 100;//低精度转换高精度，可以
		int i ='a';
		float ii = 10.1f;//计算机浮点数采用二进制表示，0.1的小数在二进制下为无限循环的小数，无法精确表述
		System.out.println(d);
		System.out.println(i);
		System.out.println(d+i+ii);
		//int f = d+i+ii;高精度转低精度会报错，不能这样定义变量
		System.out.println("------------------------------------");
		System.out.println("CompelConvert");
		//compel
		int i1 = (int)1.9;//精度丢失
		byte b = (byte)2000;//数据溢出
		System.out.println(i1);
		System.out.println(b);
		
		System.out.println("------------------------------------");
		System.out.println("StringConvert");
		//int float double char string
		int n1=1;
		float n2=2;
		double n3=3;
		String v1=n1+"";
		String v2=n2+"";
		String v3=n3+"";
		System.out.println(v1);
		System.out.println(v2);
		System.out.println(v3);
		System.out.println("将其他类型转变成了string形");
		System.out.println("------------------------------------");
		int s1= Integer.parseInt(v1);
		float s2=Float.parseFloat(v2);
		double s3=Double.parseDouble(v3);
		System.out.println(s1);
		System.out.println(s2);
		System.out.println(s3);
		System.out.println("将string形转变成了其他类型");
		System.out.println("------------------------------------");
		String str = "123";
		System.out.println(str.charAt(0));
		System.out.println(str.charAt(1));
		System.out.println(str.charAt(2));
		System.out.println("将字符串单个提出变为char，index长度为0~长度-1");
		System.out.println("------------------------------------");
	}

}
